package com.parleys.domain;

import java.util.List;

/**
 * 
 * @author David Van Droogenbroeck
 * 
 */
public class Presentation extends ParleysListObject {

	private static final long serialVersionUID = 5922238855704286201L;
	
	private Integer channelId;
	private List<Speaker> speakers;
	private String mp3;
	private String speakersString;

	public List<Speaker> getSpeakers() {
		return speakers;
	}

	public void setSpeakers(List<Speaker> speakers) {
		this.speakers = speakers;
	}

	public String getMp3() {
		return mp3;
	}

	public void setMp3(String mp3) {
		this.mp3 = mp3;
	}

	public Integer getChannelId() {
		return channelId;
	}

	public void setChannelId(Integer channelId) {
		this.channelId = channelId;
	}
	
	public String getSpeakersString() {
		if (speakersString == null) {
			speakersString = buildSpeakersString();
		}
		return speakersString;
	}

	public String buildSpeakersString() {
		StringBuilder speakersNames = new StringBuilder(256);

		int counter = 0;
		for (Speaker speaker : getSpeakers()) {
			counter++;
			if (speakersNames.length() != 0 && counter != getSpeakers().size()) {
				speakersNames.append(", ");
			} else if (speakersNames.length() != 0 && counter == getSpeakers().size()) {
				speakersNames.append(" & ");
			}
			speakersNames.append(speaker.getFullname());
		}
		
		return speakersNames.toString();
	}
}
